import time
import logging

from util import util_conf, util_args
from util import ccp_upload, ccp_list, ccp_download, ccp_delete, ccp_login, ccp_group

logging.basicConfig(level=logging.INFO, format='[%(asctime)s] %(message)s', datefmt='%Y/%m/%d %H:%M:%S')


def argv_deliver(args):
    if args.func_type == "upload":
        ccp_upload.argv_parse_upload(args)
    elif args.func_type == "list":
        ccp_list.argv_parse_list(args)
    elif args.func_type == "download":
        ccp_download.argv_parse_download(args)
    elif args.func_type == "delete":
        ccp_delete.argv_parse_delete(args)
    elif args.func_type in ["date"]:
        print(time.strftime("%a %b %d %Y"))
    elif args.func_type in ["login"]:
        ccp_login.argv_parse_login(args)
    elif args.func_type in ["logout"]:
        ccp_login.argv_parse_logout(args)
    elif args.func_type in ["info"]:
        print(f"当前用户{args.username}")
    elif args.func_type in ["group"]:
        ccp_group.argv_parse_group(args)


if __name__ == '__main__':
    _args = util_args.argv_parse_base()
    _args = util_args.argv_alias(util_conf.conf_load(util_conf.conf_init(_args)))
    _args = util_args.argv_check(_args)
    # print(_args)
    argv_deliver(_args)
